package com.cssw.fyzb.busi.api.acct;

import com.cssw.fyzb.busi.service.acct.OutAcctService;
import com.cssw.fyzb.core.exception.BizException;
import com.ydn.appserver.Action;
import com.ydn.appserver.Request;
import com.ydn.appserver.Response;
import com.ydn.appserver.annotations.Function;
import com.ydn.appserver.annotations.Parameter;
import com.ydn.appserver.annotations.Type;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 银行卡设置默认
 *
 * @description:
 * @author: zzf
 * @time: 2020/12/24 17:04
 */
@Function(description = "银行设置默认", parameters = {
        @Parameter(name = "bankId", type = Type.String, description = "主键标识", required = true)
})

@Component
public class UpdateDefaultFlag implements Action {
    private static final Logger logger = LoggerFactory.getLogger(UpdateDefaultFlag.class);

    @Autowired
    private OutAcctService outAcctService;

    @Override
    public Response execute(Request request) throws Exception {
        Long bankId = request.getLong("bankId");
        try {
            outAcctService.updateDefaultFlag(bankId);
        } catch (Exception e) {
            logger.error("", e);
            return Response.fail("设为默认失败");
        }
        return Response.success();
    }
}
